var app = getApp()
import * as appConfig from "../../../app-config.js";

Page({

  data: {
    name:"",
    phone:"",
    password:""

    
  },
  onLoad: function (options) {
  
  },
  bindSave(){
    this.saveAccount()
    
  },

  //保存账号
  saveAccount:function(){
    var that = this;
    var password = this.data.password;
    if (password.length < 6) {
      wx.showToast({
        title: '密码至少6位',
        icon: "none"
      })
      return
    }
    app.getMemInfo().then(res => {
      var agentId = res.data.agentId;
      var url = '/wx_app/agent/account/add';
      var data = {
        agentId: agentId,
        name: this.data.name,
        phone: this.data.phone,
        password: password
      }
      app.request(url, data, 'GET').then(res => {
        console.log(res)
        this.saveSuccess(res);
      })
    })
   
 

  },
  saveSuccess:function(){
    wx.navigateBack({
      url: 'shopAccount'
    })
  },

//获取账号姓名
  getNameValue:function(e){
    this.setData({
      name: e.detail.value
    })
  },

  //获取
  getPhoneValue: function (e) {
    this.setData({
      phone: e.detail.value
    })
  },

  
  getPswValue: function (e) {
    this.setData({
      password: e.detail.value
    })
  },


})